package com.blackcat.recode.controller;


import com.blackcat.recode.common.annotation.Log;
import com.blackcat.recode.common.result.AjaxResult;
import com.blackcat.recode.entity.Branch;
import com.blackcat.recode.enums.BusinessType;
import com.blackcat.recode.service.BranchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p> 分支信息表 前端控制器
 * @author blackcat 2024-09-10
 */
@RestController
@RequestMapping("/branch")
public class BranchController {

    @Autowired
    private BranchService branchService;

    @GetMapping("/getList")
    public AjaxResult getList(Integer page, Integer size, String branchName, String serviceId, String projectId) {
        return branchService.getList(page,size,branchName,serviceId,projectId);
    }

    @Log(title = "项目编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody Branch branch) {
        return branchService.edit(branch);
    }

    @GetMapping("/getOne")
    public AjaxResult getOne(String id) {
        return AjaxResult.success(branchService.getById(id));
    }

    @Log(title = "项目删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(String id) {
        return branchService.remove(id);
    }

    @GetMapping("/getBranchNameList")
    public AjaxResult getBranchNameList( String serviceId, String projectId) {
        return branchService.getBranchNameList(serviceId,projectId);
    }
}
